package com.ruoyi.crm.service.impl;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.crm.domain.CrmExpertPool;
import com.ruoyi.crm.mapper.CrmExpertPoolMapper;
import com.ruoyi.crm.service.ICrmExpertPoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 专家库Service业务层处理
 *
 * @author yanwenliang
 * @date 2024-08-15
 */
@Service
public class CrmExpertPoolServiceImpl implements ICrmExpertPoolService
{
    @Autowired
    private CrmExpertPoolMapper crmExpertPoolMapper;

    /**
     * 查询专家库
     *
     * @param expertId 专家库主键
     * @return 专家库
     */
    @Override
    public CrmExpertPool selectCrmExpertPoolByExpertId(Long expertId)
    {
        return crmExpertPoolMapper.selectCrmExpertPoolByExpertId(expertId);
    }

    /**
     * 查询专家库列表
     *
     * @param crmExpertPool 专家库
     * @return 专家库
     */
    @Override
    public List<CrmExpertPool> selectCrmExpertPoolList(CrmExpertPool crmExpertPool)
    {
        return crmExpertPoolMapper.selectCrmExpertPoolList(crmExpertPool);
    }

    /**
     * 新增专家库
     *
     * @param crmExpertPool 专家库
     * @return 结果
     */
    @Override
    public int insertCrmExpertPool(CrmExpertPool crmExpertPool)
    {
        crmExpertPool.setCreateTime(DateUtils.getNowDate());
        crmExpertPool.setCreateBy(SecurityUtils.getUsername());
        crmExpertPool.setExpertId(IdWorker.getIdStr());
        return crmExpertPoolMapper.insertCrmExpertPool(crmExpertPool);
    }

    /**
     * 修改专家库
     *
     * @param crmExpertPool 专家库
     * @return 结果
     */
    @Override
    public int updateCrmExpertPool(CrmExpertPool crmExpertPool)
    {
        crmExpertPool.setUpdateTime(DateUtils.getNowDate());
        return crmExpertPoolMapper.updateCrmExpertPool(crmExpertPool);
    }

    /**
     * 批量删除专家库
     *
     * @param expertIds 需要删除的专家库主键
     * @return 结果
     */
    @Override
    public int deleteCrmExpertPoolByExpertIds(Long[] expertIds)
    {
        return crmExpertPoolMapper.deleteCrmExpertPoolByExpertIds(expertIds);
    }

    /**
     * 删除专家库信息
     *
     * @param expertId 专家库主键
     * @return 结果
     */
    @Override
    public int deleteCrmExpertPoolByExpertId(Long expertId)
    {
        return crmExpertPoolMapper.deleteCrmExpertPoolByExpertId(expertId);
    }

    /**
     * 获取专家信息
     * @param crmExpertPool
     * @return
     */
    @Override
    public CrmExpertPool getExpertOne(CrmExpertPool crmExpertPool) {
        return crmExpertPoolMapper.getExpertOne(crmExpertPool);
    }

    @Override
    public CrmExpertPool getExpertByName(String name) {
        return crmExpertPoolMapper.getExpertByName(name);
    }

}
